12. Postgres Command Line Applications

Postgres Command Line Applications Heading

Postgres Command Line Applications

ND004 C01 L02 16 Postgres Command Line Applications

Postgres CLI tools

Keep this as a general reference. You'll be using these commands quite a lot if you are building web apps with Postgres.

Log in as a particular user

Default installed user is called postgres

sudo -u <username> -i

e.g. sudo -u bob -i

Create a new database

createdb <database_name>

e.g. createdb mydb

Destroy a database

dropdb <database_name>

e.g. dropdb mydb

Reset a database

dropdb <database_name> && createdb <database_name>

e.g. dropdb mydb && createdb mydb

Try it yourself!

Gain technical proficiency in managing postgres databases by practicing creating, dropping, and resetting databases. Do this in your terminal, if you successfully installed Postgres on your local computer, or interact with the terminal in this workspace below, which already has Postgres installed.

Workspace

This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity , so you may be able to download them there.

Workspace Information:

  • Default file path:
  • Workspace type: jupyter-lab
  • Opened files (when workspace is loaded): n/a